<?php
	header('content-type:text/html; charset=utf-8');

$uu = 'username';
$pwd = 'password';

$app_key = 'app_key';
$to_uid_arr = array(
	111,222,
);

$post_url = 'http://api.t.sina.com.cn/friendships/create.json';
// cookie文件路径
$cookie_file = tempnam('F:/temp/cookie','cookie');

// 关注微博
foreach($to_uid_arr as $to_uid){
	$post_fields = array();
	$post_fields['source'] = $app_key;
	$post_fields['user_id'] = $to_uid;
	$ss = '';
	foreach($post_fields as $k => $one){
		$ss .= $k . '=' . $one . '&';
	}
	$ch = curl_init($post_url);
	curl_setopt($ch, CURLOPT_HEADER, 0);
	curl_setopt($ch, CURLOPT_RETURNTRANSFER, 0);
	curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie_file);
	curl_setopt($ch, CURLOPT_POST, 1);
	curl_setopt($ch, CURLOPT_POSTFIELDS, $ss);
	curl_setopt($ch, CURLOPT_TIMEOUT, 5); 

	curl_setopt( $ch, CURLOPT_USERPWD , "$uu:$pwd");  

	echo(curl_exec($ch));
	curl_close($ch);

	sleep(5);
}

// 清理cookie文件
unlink($cookie_file);

?>